<?php
declare(strict_types=1);

namespace App\AdminApi\Module\User\Api;

use App\AdminApi\AdminApiBasicsController;
use App\AdminApi\Module\User\Service\UserService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Psr\Http\Message\ResponseInterface;
use Zms\Guard\Auth;
use Zms\HyperfResponse\Response;

#[
    Auth(guard: self::GUARD, label: ['用户管理'], app: self::APP),
    Controller(prefix: "/admin-api/user", server: self::SERVER)
]
class OverviewController extends AdminApiBasicsController
{
    #[Inject]
    protected UserService $user;


    #[
        GetMapping('overview'),
        Auth(label: ['用户概览'], sign: 'user.overview')
    ]
    public function overview(): ResponseInterface
    {
        return Response::Api()->success(
            data: $this->user->getOverviewData()
        );
    }


    #[
        GetMapping('register-chart'),
        Auth(label: ['注册概览'], relyon: ['user.overview'])
    ]
    public function RegisterChart(): ResponseInterface
    {
        return Response::Api()->success(
            data: $this->user->getRegisterChart()
        );
    }


    #[
        GetMapping('level-chart'),
        Auth(label: ['等级概览'], relyon: ['user.overview'])
    ]
    public function LevelChart(): ResponseInterface
    {
        return Response::Api()->success(
            data: $this->user->getLevelChart()
        );
    }
}